package com.levi.fallback;

import com.levi.controller.product.ProductControllerApi;
import com.levi.pojo.Product;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @author shentong
 * @since 2022/6/6 9:19 PM
 */
@Component
public class ProductFallbackFactory implements FallbackFactory<ProductControllerApi> {
    @Override
    public ProductControllerApi create(Throwable throwable) {
        return new ProductControllerApi() {
            @Override
            public Boolean save(String name,Integer stock) {
                return false;
            }

            @Override
            public String decutProduct(Integer id, Integer count) {
                System.out.println("decutProduct方法熔断降级:=>>>"+throwable);
                return "fail";
            }

            @Override
            public Product getProductById(Integer id) {
                System.out.println(throwable);
                return null;
            }

            @Override
            public String configInfo() {
                return null;
            }

            @Override
            public String gateway() {
                return null;
            }

            @Override
            public String testSentinel() {
                return null;
            }
        };
    }
}
